{template '_header'}
<link rel="stylesheet" type="text/css" href="../addons/ewei_shopv2/template/mobile/default/static/css/coupon.css?v=2.0.0">
<div class='fui-page order-create-page'>
    <div class="fui-header">
        <div class="fui-header-left">
            <a class="back"></a>
        </div>
        <div class="title">确认订单</div>
        <div class="fui-header-right" data-nomenu="true">&nbsp;</div>
    </div>
    <div class='fui-content  navbar'>

        {if count($carrier_list)>0 && !$isverify && !$isvirtual}
        <div id="carrierTab" class="fui-tab fui-tab-danger">
            <a data-tab="tab1" class="active">快递配送</a>
            <a data-tab="tab2">上门自提</a>
        </div>
        {/if}

        {if  !$isverify && !$isvirtual}
        <!--地址选择-->
        <div class="fui-list-group" id='addressInfo' data-addressid="{php echo intval($address['id'])}">
            <a  class="fui-list {if empty($address)}external{/if}"
                {if empty($address)}
                href="{php echo mobileUrl('member/address/post')}"
                {else}
                href="{php echo mobileUrl('member/address/selector')}"
                {/if}
            data-nocache="true">
            <div class="fui-list-media">
                <i class="icon icon-location"></i>
            </div>
            <div class="fui-list-inner" >
                <div class="title has-address" {if empty($address)}style='display:none'{/if}><span class='realname'>{$address['realname']}</span> <span class='mobile'>{$address['mobile']}</span></div>
            <div class="text has-address" {if empty($address)}style='display:none'{/if}><span class='address'>{$address['province']}{$address['city']}{$address['area']} {$address['address']}</span></div>
        <div class="text no-address" {if !empty($address)}style='display:none'{/if}><i class="icon icon-add"></i> 添加收货地址</div>
</div>
<div class="fui-list-angle">
    <div class="angle"></div>
</div>
</a>
</div>


<!--自提点选择-->
<div class="fui-list-group"  id="carrierInfo" style="display: none">
    <a class="fui-list" href="{php echo mobileUrl('store/selector', array('type'=>1,'merchid'=>$merch_id))}" data-nocache='true'>
        <div class="fui-list-media">
            <i class="icon icon-shop"></i>
        </div>

        <div class="fui-list-inner">
            <div class="title"><span class='storename'>{$carrier_list[0]['storename']}</span></div>
            <div class="subtitle"><span class='realname'>{$carrier_list[0]['realname']}</span> <span class='mobile' id="carrierInfo_mobile">{$carrier_list[0]['mobile']}</span></div>
            <div class="text"><span class='address'>{$carrier_list[0]['address']}</span></div>
        </div>
        <div class="fui-list-angle">
            <div class="angle"></div>
        </div>
    </a>
</div>
{/if}
<!--联系填写-->
{if $sysset['set_realname']==0 || $sysset['set_mobile']==0}
<div class="fui-cell-group sm" id="memberInfo" {if !$isverify && !$isvirtual}style="display:none"{/if}>
{if $sysset['set_realname']==0}
<div class="fui-cell">
    <div class="fui-cell-label sm">联系人</div>
    <div class="fui-cell-info"><input type="text" placeholder="请输入联系人" data-set="{$sysset['set_realname']}" name='carrier_realname' class="fui-input" value="{$member['realname']}"/></div>
</div>
{/if}
{if $sysset['set_mobile']==0}
<div class="fui-cell">
    <div class="fui-cell-label sm">联系电话</div>
    <div class="fui-cell-info"><input type="tel" placeholder="请输入联系电话" data-set="{$sysset['set_mobile']}" name='carrier_mobile' class="fui-input" value="{$member['carrier_mobile']}"/></div>
</div>
{/if}
</div>
{/if}


<div class="fui-list-group" >

    {loop $goods_list $key $list}
    <div class="fui-list-group-title"><i class="icon icon-shop"></i > {$list['shopname']}</div>
    {loop $list['goods'] $g}
    <input type='hidden' name='goodsid[]' value="{$g['id']}" />
    <input type='hidden' name='optionid[]' value="{$g['optionid']}" />
    <div class="fui-list goods-item">
        <div class="fui-list-media">
            <a href="{php echo mobileUrl('goods/detail',array('id'=>$g['goodsid']))}">
                <img src="{php echo tomedia($g['thumb'])}" class="round package-goods-img">
            </a>
        </div>
        <div class="fui-list-inner">
            <a href="{php echo mobileUrl('goods/detail',array('id'=>$g['goodsid']))}">
                <div class="text">
                    {if $g['seckillinfo'] && $g['seckillinfo']['status']==0}<span class='fui-label fui-label-danger'>{$g['seckillinfo']['tag']}</span>{/if}
                    {if empty($g['isnodiscount']) && !empty($g['dflag'])}<span class='fui-label fui-label-danger'>折扣</span>{/if}
                    {$g['title']}
                </div>
                {if !empty($g['optionid'])}
                <div class="text">
                    {$g['optiontitle']}
                </div>
                {/if}
            </a>
        </div>
        <div class='fui-list-angle'>
            <span class="price ">&yen; <span class='marketprice'>{if $g['packageprice'] > $g['unitprice']}{$g['packageprice']}{else if $g['marketprice'] > $g['unitprice']}{$g['marketprice']}{else}{$g['unitprice']}{/if}</span></span>
            <span class="total">
                {if $changenum && !$isgift}
                <div class="fui-number small" data-value="{$total}" data-unit="{$g['unit']}" data-maxbuy="{$g['totalmaxbuy']}" data-minbuy="{$g['minbuy']}" data-goodsid="{$g['goodsid']}">
                    <div class="minus">-</div>
                    <input class="num shownum" type="tel" name="" value="{$total}"/>
                    <div class="plus">+</div>
                </div>
                {else}
                    x{$g['total']}<input class="num shownum" type="hidden" name="" value="{$total}"/>
                {/if}
            </span>
        </div>

</div>
{/loop}
{/loop}





<script type="text/javascript">
    $(function(){
        $(".package-goods-img").height($(".package-goods-img").width());
    })
</script>
<div class='fui-cell-group'>
    {loop $giftGood $item}
    <div class="fui-cell" style="padding:0 0 0 0.5rem;">
        <div class="fui-list goods-item" style="width:100%;">
            <div class="fui-list-media image-media" style="position: initial;">
                <a href="javascript:void(0);">
                    <img class="round" src="{php echo tomedia($item['thumb'])}" data-lazyloaded="true">
                </a>
            </div>
            <div class="fui-list-inner">
                <a href="javascript:void(0);">
                    <div class="text">
                        {$item['title']}<br /><span class="fui-label fui-label-danger">赠品</span>
                    </div>
                </a>
            </div>
            <div class='fui-list-angle'>
                <span class="price">&yen;<del class='marketprice'>{$item['marketprice']}</del></span>
            </div>
        </div>
    </div>
    {/loop}
    {if $hasinvoice}
    <div class="fui-cell">
        <div class="fui-cell-label">发票抬头</div>
        <div class="fui-cell-info"><input type='text' class='fui-input' value="{$invoicename}" id='invoicename' /></div>
    </div>
    {/if}
    <div class="fui-cell">
        <div class="fui-cell-info" style="text-align: right;">共 <span id='goodscount' class='text-danger'>{$total}</span> 件商品 合计：<span class="text-danger">&yen; <span class='{if !$packageid && empty($exchangeOrder)}goodsprice{/if}'>{php echo number_format($goodsprice,2)}</soan></span></div>
    </div>

</div>
</div>

{if $isgift}
<input type="hidden" name="giftid" id="giftid" value="{$giftid}">
<div class="fui-cell-group sm ">
    <div class="fui-cell">
        {if count($gifts)>1}
        <div class='fui-cell-text fui-cell-giftclick'>
            赠品：<label id="gifttitle">请选择赠品</label>
        </div>
        {else}
        {loop $gifts $item}
        <div class='fui-cell-text' onclick="javascript:window.location.href='{php echo mobileUrl('goods/gift',array('id'=>$item['id']))}'">
            赠品：{$gifttitle}
        </div>
        {/loop}
        {/if}
        <div class='fui-cell-remark'></div>
    </div>
</div>
{/if}

{if !empty($order_formInfo)}
{template 'diyform/formfields'}
{else}
<div class="fui-cell-group sm ">
    <div class="fui-cell">
        <div class="fui-cell-info"><input type="text" class="fui-input" id='remark' placeholder="选填: 买家留言(50字以内)" maxlength="50"></div>
    </div>
</div>
{/if}
{if empty($exchangeOrder)}
<div class="fui-cell-group  sm">

    <div id='coupondiv' class="fui-cell fui-cell-click" {if $couponcount<=0}style='display:none'{/if}>
    <div class='fui-cell-label' style='width:auto;'>优惠券</div>
    <div class='fui-cell-info'></div>
    <div class='fui-cell-remark'>
        <div class='badge badge-danger' {if $couponcount<=0}style='display:none'{/if}>{$couponcount}</div>
    <span class='text' {if $couponcount>0}style='display:none'{/if}>无可用</span>
</div>
</div>


{if $deductcredit>0}
<div class="fui-cell">
    <div class="fui-cell-label" style="width: auto;"> <span id="deductcredit_info" class='text-danger'>{$deductcredit}</span> {$_W['shopset']['trade']['credittext']}可抵扣 <span id="deductcredit_money" class='text-danger'>{php echo number_format($deductmoney,2)}</span> 元</div>
    <div class="fui-cell-info"></div>
    <div class="fui-cell-remark noremark"><input id="deductcredit" data-credit="{$deductcredit}" data-money='{$deductmoney}' type="checkbox" class="fui-switch fui-switch-small fui-switch-success pull-right"></div>
</div>
{/if}

{if $deductcredit2>0}
<div class="fui-cell">
    <div class="fui-cell-label" style="width: auto;">{$_W['shopset']['trade']['moneytext']}可抵扣 <span id='deductcredit2_money' class="text-danger">{php echo number_format($deductcredit2,2)}</span>元</div>
    <div class="fui-cell-info"></div>
    <div class="fui-cellfui-cell-remark noremarkinfo"><input id="deductcredit2" data-credit2="{$deductcredit2}" type="checkbox"  class="fui-switch fui-switch-small fui-switch-success pull-right"></div>
</div>
{/if}

</div>

{if !empty($stores)}
<script language='javascript' src='http://api.map.baidu.com/api?v=2.0&ak=ZQiFErjQB7inrGpx27M1GR5w3TxZ64k7'></script>
<div class='fui-according-group'>
    <div class='fui-according'>
        <div class='fui-according-header'>
            <i class='icon icon-shop'></i>
            <span class="text">适用门店</span>
            <span class="remark"><div class="badge">{php echo count($stores)}</div></span>
        </div>
        <div class="fui-according-content store-container">
            {loop $stores $item}
            <div  class="fui-list store-item" data-lng="{php echo floatval($item['lng'])}" data-lat="{php echo floatval($item['lat'])}">
                <div class="fui-list-media">
                    <i class='icon icon-shop'></i>
                </div>
                <div class="fui-list-inner store-inner">
                    <div class="title"><span class='storename'>{$item['storename']}</span></div>
                    <div class="text">
                        地址: <span class='realname'>{$item['address']}</span>
                    </div>
                    <div class="text">
                        电话: <span class='address'>{$item['tel']}</span>
                    </div>
                </div>
                <div class="fui-list-angle ">
                    {if !empty($item['tel'])}<a href="tel:{$item['tel']}" class='external '><i class=' icon icon-phone' style='color:green'></i></a>{/if}
                    <a href="{php echo mobileUrl('store/map',array('id'=>$item['id'],'merchid'=>$item['merchid']))}" class='external' ><i class='icon icon-location' style='color:#f90'></i></a>
                </div>
            </div>
            {/loop}
        </div>
        <div id="nearStore" style="display:none">
            <div class='fui-list store-item'  id='nearStoreHtml'></div>
        </div>
    </div></div>
{/if}
{/if}


<div class="fui-cell-group sm">
    <input type="hidden" id="weight" name='weight' value="{$weight}" />
    {if !empty($exchangeOrder)}
    <div class="fui-cell">
        <div class="fui-cell-label" >兑换券</div>
        <div class="fui-cell-info"></div>
        <div class="fui-cell-remark noremark"><span style="color: red;">- &yen; {php echo number_format($exchangecha,2);}</span></div>
    </div>
    {/if}
    <div class="fui-cell">
        <div class="fui-cell-label" >商品小计</div>
        <div class="fui-cell-info"></div>
        <div class="fui-cell-remark noremark">&yen; <span class='{if !$packageid && empty($exchangeOrder)}goodsprice{/if}'>{if !empty($exchangeOrder)}{$exchangeprice}{else}{php echo number_format($goodsprice,2)}{/if}</span></div>
    </div>
    {if empty($exchangeOrder)}
    {if !$packageid}
    <div class="fui-cell"  style="display: none">
        <div class="fui-cell-label" style='width:auto' >重复购买优惠</div>
        <div class="fui-cell-info"></div>
        <div class="fui-cell-remark noremark">-￥<span id='showbuyagainprice' class='showbuyagainprice'></span></div>
        <input type="hidden" id='buyagain' class='buyagainprice'  value="{php echo number_format($buyagainprice,2)}" />
    </div>

    <div class="fui-cell istaskdiscount"  style="display: none">
        <div class="fui-cell-label" style='width:auto' >任务活动优惠</div>
        <div class="fui-cell-info"></div>
        <div class="fui-cell-remark noremark">-&yen; <span id='showtaskdiscountprice' class='showtaskdiscountprice'></span></div>
        <input type="hidden" id='taskdiscountprice' class='taskdiscountprice'  value="{php echo number_format($taskdiscountprice,2)}" />
    </div>

    <div class="fui-cell discount"  style="display: none">
        <div class="fui-cell-label" style='width:auto' >会员优惠</div>
        <div class="fui-cell-info"></div>
        <div class="fui-cell-remark noremark">-&yen; <span id='showdiscountprice' class='showdiscountprice'></span></div>
        <input type="hidden" id='discountprice' class='discountprice'  value="{php echo number_format($discountprice,2)}" />
    </div>

    <div class="fui-cell isdiscount"  style="display: none">
        <div class="fui-cell-label" style='width:auto' >促销优惠</div>
        <div class="fui-cell-info"></div>
        <div class="fui-cell-remark noremark">-&yen; <span id='showisdiscountprice' class='showisdiscountprice'></span></div>
        <input type="hidden" id='isdiscountprice' class='isdiscountprice'  value="{php echo number_format($isdiscountprice,2)}" />
    </div>

    <div class="fui-cell" id="deductenough" {if !$saleset['showenough']}style='display:none'{/if}>
        <div class="fui-cell-label" style='width:auto' >商城单笔满 <span id="deductenough_enough" class='text-danger'>{php echo number_format($saleset['enoughmoney'],2)}</span> 元立减</div>
        <div class="fui-cell-info"></div>
        <div class="fui-cell-remark noremark">-&yen; <span id='deductenough_money'>{if $saleset['showenough']}{php echo number_format($saleset['enoughdeduct'],2)}{/if}</span></div>
    </div>

    <div class="fui-cell" id="merch_deductenough" {if !$merch_saleset['merch_showenough']}style='display:none'{/if}>
        <div class="fui-cell-label" style='width:auto' >商户单笔满 <span id="merch_deductenough_enough" class='text-danger'>{php echo number_format($merch_saleset['merch_enoughmoney'],2)}</span> 元立减</div>
        <div class="fui-cell-info"></div>
        <div class="fui-cell-remark noremark">-&yen; <span id='merch_deductenough_money'>{if $merch_saleset['merch_showenough']}{php echo number_format($merch_saleset['merch_enoughdeduct'],2)}{/if}</span></div>
    </div>

    <div class="fui-cell" id="seckillprice"  {if $seckill_price<=0}style="display: none"{/if}>
        <div class="fui-cell-label" style='width:auto' >秒杀优惠</div>
        <div class="fui-cell-info"></div>
        <div class="fui-cell-remark noremark">-&yen; <span id="seckillprice_money">{php echo number_format($seckill_price,2)}</span></div>
    </div>
{/if}
    {/if}
    <div class="fui-cell">
        <div class="fui-cell-label" >运费</div>
        <div class="fui-cell-info"></div>
        <div class="fui-cell-remark noremark">&yen; <span class='{if !$packageid && empty($exchangeOrder)}dispatchprice{/if}'>{if !empty($exchangeOrder)}{$exchangepostage}{else}{php echo number_format($dispatch_price,2)}{/if}</span></div>
    </div>


<div class="fui-cell" id='coupondeduct_div' style='display:none'>
    <div class="fui-cell-label" style='width:auto' id='coupondeduct_text' ></div>
    <div class="fui-cell-info"></div>
    <div class="fui-cell-remark noremark">-&yen; <span id="coupondeduct_money">0</span></div>
</div>
</div>

</div>
{if $isgift}
<div id='gift-picker-modal' style="margin:-100%;">
    <div class='gift-picker'>
        <div class="fui-cell-group fui-sale-group" style='margin-top:0;'>
            <div class="fui-cell">
                <div class="fui-cell-text dispatching">
                    请选择赠品:
                    <div class="dispatching-info" style="max-height:12rem;overflow-y: auto ">
                        {loop $gifts $item}
                        <div class="fui-list goods-item align-start" data-giftid="{$item['id']}">
                            <div class="fui-list-media">
                                <input type="radio" name="checkbox" class="fui-radio fui-radio-danger gift-item" value="{$item['id']}" style="display: list-item;">
                            </div>
                            <div class="fui-list-inner">
                                {loop $item['gift'] $gift}
                                <div class="fui-list">
                                    <div class="fui-list-media image-media" style="position: initial;">
                                        <a href="javascript:void(0);">
                                            <img class="round" src="{php echo tomedia($gift['thumb'])}" data-lazyloaded="true">
                                        </a>
                                    </div>
                                    <div class="fui-list-inner">
                                        <a href="javascript:void(0);">
                                            <div class="text">
                                                {$gift['title']}
                                            </div>
                                        </a>
                                    </div>
                                    <div class='fui-list-angle'>
                                        <span class="price">&yen;<del class='marketprice'>{$gift['marketprice']}</del></span>
                                    </div>
                                </div>
                                {/loop}
                            </div>
                        </div>
                        {/loop}
                    </div>
                </div>
            </div>
            <div class='btn btn-danger block'>确定</div>
        </div>
    </div>
</div>
{/if}

<div class="fui-navbar order-create-checkout">
    <a href="javascript:;" class="nav-item total">
        <p>{if $packageid}<span class="text-danger" style="font-size: 0.6rem;">(套餐优惠&yen;{php echo number_format($marketprice-$goodsprice,2)})</span>{/if}
            需付：<span class="text-danger ">&yen; <span class="{if !$packageid && empty($exchangeOrder)}totalprice{/if}">
                {if !empty($exchangeOrder)}{$exchangerealprice}{else}{php echo number_format($realprice,2)}{/if}</span></span>
        </p>
    </a>
    <a href="javascript:;" class="nav-item btn btn-danger buybtn">立即支付</a>
</div>
{template 'sale/coupon/util/picker'}
<script language='javascript'>require(['biz/order/create'], function (modal) {modal.init({php echo json_encode($createInfo)}); });</script>
</div>
{template '_footer'}